﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.Business;

namespace University.Workshop.Presenters.OtbData.Search
{
    public class PresenterSearchOtbData
    {
        ISearchOtbDataView view;
        public PresenterSearchOtbData(ISearchOtbDataView view)
        {
            this.view = view;
        }

        public void SearchOtbData()
        {
            try 
            {
                Model.OtbData otb = new Model.OtbData() { Name = view.OtbName, 
                                                            Managment = view.Managment, 
                                                            Person = new Model.Person() {Names = view.PresidentNamesRelative, 
                                                                                            LastNames = view.PresidentLastNamesRelative } };
                view.OtbsFinded = ManagerOtbData.SearchOtbDataByParameter(otb);
            }
            catch( Exception ex)
            {
                view.OtbsFinded = null;
                view.NotifyErrorMessage(ex.Message);
            }
        }
    }
}
